﻿@model Siser.Web.Models.CReporteAmbiental
@{
    ViewBag.Title = "Reporte ambiental";
}

<h2>Reporte Ambiental</h2>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
 <script src="@Url.Content("~/Scripts/Propios.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.10.3.custom.js")" type="text/javascript"></script>
<link rel="stylesheet" href="@Url.Content("~/Content/jquery-ui-1.10.3.custom.css")" type="text/css"/>

@using (Html.BeginForm("reporteambiental1", "Reporte", FormMethod.Get))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Registro de Datos Informe Período Radiológico</legend>
        <div style="clear:both;">
            <div class="editor-label2"><br />Fecha inicio</div>
            <div class="editor-field2">
                @Html.TextBoxFor(model => model.fechaInicio, new { @readonly = "readonly" })
                @Html.ValidationMessageFor(model => model.fechaInicio)
            </div>
        </div>
        <div style="clear:both;">
            <div class="editor-label2"><br />Fecha fin</div>
            <div class="editor-field2">
                @Html.TextBoxFor(model => model.fechaFin, new { @readonly = "readonly" })
                @Html.ValidationMessageFor(model => model.fechaFin)
            </div>
        </div>

        <div style="clear:both;">
           <div class="editor-label2"><br />Región</div>
             <div class="editor-field2">
                @Html.DropDownList("region","Seleccione una opción")
                @Html.ValidationMessageFor(model => model.region)
            </div>
        </div>
        
        <div style="clear:both;">
            <div class="editor-label2"><br />Empresa</div>
             <div class="editor-field2">
                @Html.DropDownList("empresa", "Seleccione una opción")
                @Html.ValidationMessageFor(model => model.empresa)
            </div>
        </div>

        <div style="clear:both;">
            <div class="editor-label2"><br />Planta</div>
             <div class="editor-field2">
                @Html.DropDownList("area", "Seleccione una opción")
                @Html.ValidationMessageFor(model => model.area)
            </div>
        </div>

        <div style="clear:both;">
        <p>
            <input type="submit" value="Generar" onclick="ClickBoton()" />
        </p>
        </div>

        @Html.Hidden("bloqueo")

    </fieldset>
    }   
    <script type="text/javascript">
     $(function () {
         $("#fechaInicio,#fechaFin").datepicker();
     });

        $(document).ready(function () {
            if (document.getElementById("bloqueo").value == '1') {
                document.getElementById("area").disabled = true;
                document.getElementById("region").disabled = true;
                document.getElementById("empresa").disabled = true;
            }
            $("#empresa").change(function () {
                cambiaElementos($("#empresa").val());
            });
            $("#area").change(function () {
                cambiaInstalaciones($("#area").val());
            });
        });
        function cambiaElementos(cat) {
            var dd = document.getElementById("area");
            dd.options.length = 0;
            dd.selectedIndex = 0;
            dd.disabled = true;
            $("#area").ajaxError(function (event, request, settings) {
                dd.options[0] = new Option("Seleccione una opción");
            });
            $.getJSON('@Url.Action("getPlantasPorEmpresa")', { empresa: cat }, function (data) {
                dd.disabled = false;
                $.each(data, function (i, item) {
                    dd.options[i + 1] = new Option(item.Text, item.Value);
                });
                dd.options[0] = new Option("Seleccione una opción");
            });
        }
        function ClickBoton() {
            document.getElementById("area").disabled = false;
            document.getElementById("region").disabled = false;
            document.getElementById("empresa").disabled = false;
        }
    </script>

 <a href="javascript:history.back(1)">Volver</a>
